/*
 * @Author: zhiming
 * @Date: 2020-08-20 15:21:54
 * @LastEditTime: 2020-08-25 14:55:23
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \shopping_mall_app\src\pages\home\goods\details_content.js
 */
import React from 'react';
import * as utils from '../../../assets/js/utils/index';
import * as Request from '../../../services/home/details';
import Css from '../../../assets/css/goods/details_content.css';

class GoodsDetailsContent extends React.Component{
    constructor(props){
        super(props);
        this.state = {
            gid: !!props.location.search ? utils.localParam(props.location.search).search.gid : '',
            aContent: ''
        }
        // this.gid = utils.localParam(this.props.location.search).search.gid
    }

    componentDidMount(){
        Request.getGoodsDetails(this.state.gid).then(res => {
            res.code === 200 && this.setState({ aContent: res.data.bodys });
        });
    }

    componentWillUnmount(){
        //页面卸载时，重写setState,避免内存溢出
        this.setState = (state, callback) => {
            return ;
        }
    }

    render(){
        return (
            <div className={Css['content']}>
                <div dangerouslySetInnerHTML={{__html:this.state.aContent}}></div>
            </div>
        )
    }
}

export default GoodsDetailsContent;